package com.ruicar.afs.cloud.image.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruicar.afs.cloud.common.core.entity.BaseEntity;
import com.ruicar.afs.cloud.image.vo.UploadInputVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * @Description:
 * @Author: fangchenliang
 * @Date: 2020/6/1 9:43
 */
@Data
@TableName("com_attachement_file")
@ApiModel(value = "影像文件")
public class ComAttachmentFile extends BaseEntity<ComAttachmentFile> {
    /**
     * 业务编号;例如合同号或者贷后变更案件号
     */
    private String busiNo;
    /**
     * 所属业务编号;属于某个申请编号
     */
    private String belongNo;
    /**
     * 附件编号
     */
    private String attachmentCode;
    /**
     * 附件名称
     */
    private String attachmentName;
    /**
     * 附件状态;待确认，合格，不合格，修正，废弃等
     */
    private String fileStatus;
    /**
     * 文件类型
     */
    private String fileType;
    /**
     * 文件历史版本;v1,v2,v3
     */
    private String historyVersion;
    /**
     * 是否电子签文件
     */
    private String isElectronic;
    /**
     * 电子签文件编号
     */
    private String electronicNo;
    /**
     * 文件名
     */
    private String fileName;
    /**
     * 文件编号;MD5值
     */
    private String fileId;
    /**
     * 文件缩略图编号;MD5值
     */
    private String thumbnailId;
    /**
     * 上传时间
     */
    private Date uploadTime;

    /**归档类型（数据字典与归档系统保持一致）*/
    private String archiveClass;

    /**
     * 备注;预留字段，可扩展三级
     */
    private String remake;

    /**文件来源*/
    private String fileSource;

    @TableField(exist = false)
    @ApiModelProperty(value = "影像文件路径")
    private String imageUrl;

    @TableField(exist = false)
    @ApiModelProperty(value = "缩略图文件路径")
    private String thumUrl;

    @TableField(exist = false)
    @ApiModelProperty(value = "文件流")
    private byte[] imageFlow;

    @TableField(exist = false)
    @ApiModelProperty(value = "合同关联关系表签约状态")
    private String signStatus;

    public static ComAttachmentFile convertFrom(ComAttachmentFile comAttachmentFile, UploadInputVo uploadInputVo) {
        comAttachmentFile.setBusiNo(uploadInputVo.getBusiNo());
        comAttachmentFile.setBelongNo(uploadInputVo.getBelongNo());
        comAttachmentFile.setAttachmentCode(uploadInputVo.getAttachmentId());
        comAttachmentFile.setAttachmentName(uploadInputVo.getAttachmentName());
        comAttachmentFile.setFileType(uploadInputVo.getFileType());
        comAttachmentFile.setFileName(uploadInputVo.getFileName());
        comAttachmentFile.setFileId(uploadInputVo.getFileMd5());
        comAttachmentFile.setUploadTime(new Date());
        return comAttachmentFile;
    }

}
